<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量    
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	// 将 "项目路径basePath" 放入pageContext中，待以后用EL表达式读出。    
	pageContext.setAttribute("basePath", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>


<!-- <link rel="stylesheet" type="text/css"
	href="<%= basePath%>style/css/bootstrap.css" /> -->
<link rel="stylesheet" type="text/css"
	href="<%= basePath%>style/css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css"
	href="<%= basePath%>style/css/style.css" />

<link rel="stylesheet" type="text/css"
	href="<%=basePath%>/mallstyle/css/bootstrap.min2.css">
<link rel="stylesheet" type="text/css"
	href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/bootstrap-responsiv.css">


<link rel="stylesheet" type="text/css"
	href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstra.css">
<link rel="stylesheet" href="<%=basePath%>/mallstyle/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%=basePath%>/mallstyle/css/bootstrap-theme.min.css" />
<script type="text/javascript"
	src="<%=basePath%>/mallstyle/js/jquery-3.0.0.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/mallstyle/js/bootstrap.min.js"></script>


<script type="text/javascript" src="<%= basePath%>style/js/jquery.js"></script>
<script type="text/javascript" src="<%= basePath%>style/js/bootstrap.js"></script>
<script type="text/javascript" src="<%= basePath%>style/js/ckform.js"></script>
<script type="text/javascript" src="<%= basePath%>style/js/common.js"></script>



<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}

.errorClass {
	display: inline;
	color: red;
}

@media ( max-width : 980px) {
	/* Enable use of floated navbar text */
	.navbar-text.pull-right {
		float: none;
		padding-left: 5px;
		padding-right: 5px;
	}
}
</style>
</head>
<body>

	<div class="row-fluid">

		<div>
				<ul class="breadcrumb">
					<li>分类信息管理 <span class="divider">></span>
					</li>
					<li>分类信息查看</li>
				</ul>
			</div>
	</div>

	<h2 style="text-align: center;">分类列表</h2>
	<table style="width: 1000px;"
		class="table table-bordered table-hover definewidth m10">
		<caption class="captionAddOneLevel">
			<button class="btn btn-primary" data-toggle="modal"
				data-target="#myModal">添加一级分类</button>
			<%@include file="../category/addCategory.jsp"%>
			<%@include file="../category/addCategory2.jsp"%>
			<%@include file="../category/editCategory.jsp"%>
			<%@include file="../category/editCategory2.jsp"%>
		</caption>
		<tr class="trTitle">
			<th width="30%">分类名称</th>
			<th width="50%">描述</th>
			<th width="20%">操作</th>
		</tr>
		<c:forEach items="${parents }" var="parent">
			<tr>
				<td class="tableleft"><font size="3px" color="bule"><b>${parent.catName }</b></font></td>
				<td class="tableleft"><font size="3px" color="bule"><b>${parent.catDetail }</b></font></td>
				<td class="tableleft"><font size="3px"><b> 
				<a href="javascript:void(0)" onclick="addCategory2(this,${parent.catId })">添加二级分类</a> 
				<a href="javascript:void(0)" onclick="editCategory(this,${parent.catId })">修改</a>
							<c:if test="${empty parent.child }">
								<a onclick="return confirm('您是否真要删除该一级分类？')"
									href="<%=path %>/rest/category/deleteCategory?catid=${parent.catId }">删除</a>
							</c:if>
					</b></font></td>
			</tr>
			<c:forEach items="${parent.child }" var="child">
				<tr>
					<td>${child.catName }</td>
					<td>${child.catDetail }</td>
					<td align="right">
					<a href="javascript:void(0)" onclick="editCategory2(this,${child.catId })">修改</a>
						<a onclick="return confirm('您是否真要删除该二级分类？')"
						href="<%=path %>/rest/category/deleteCategory?catid=${child.catId }">删除</a>
					</td>
				</tr>
			</c:forEach>
		</c:forEach>

	</table>

	<script> 
		function addCategory2(obj,id) {  
        var tds = $(obj).parent().parent().parent().parent().find('td');  
          $('#catCid').val(id);  
          $('#catName1').val(tds.eq(0).text());  
          $('#myModal2').modal('show');  
    }  
    </script>
	<script> 
		function editCategory(obj,id) {  
        var tds = $(obj).parent().parent().parent().parent().find('td');  
          $('#catCid1').val(id);  
          $('#editcatName').val(tds.eq(0).text());  
          $('#editcatDetail').val(tds.eq(1).text());  
          $('#editModal').modal('show');  
    }  
    </script>
	<script> 
		function editCategory2(obj,id) {  
        var tds = $(obj).parent().parent().find('td');  
          $('#catId2').val(id);
         // $('#catName11').val(tds.eq(0).text());  
          $('#editcatName2').val(tds.eq(0).text());  
          $('#editcatDetail2').val(tds.eq(1).text());  
          $('#editModal2').modal('show');  
    }  
    </script>
</body>
</html>
